package com.myCode.lambda;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;

/**
 * lambda 表达式学习
 */
public class LambdaDemo {
    public static void main(String[] args) {
        // Button button = new Button();
        //
        // button.addActionListener(event -> System.out.println("lambda 表达式"));
        //
        // BinaryOperator<Long> add = (x, y) -> x + y;
        String name = "zhangsan";

        // name = "lisi";

        Runnable runnable = () -> System.out.println(name);
        runnable.run();

        ThreadLocal threadLocal = new ThreadLocal();

        ArrayList<String> strings = new ArrayList<>();
        strings.add("lisi");
        strings.add("wangwu");
        strings.add("zhangsan");
        strings.add("maliu");
        strings.add("zhangsan");
        strings.add("zhaoqi");
        strings.add("zhangsan");

        // filter 过滤
        long zhangsan = strings.stream().filter(string -> string.equals("zhangsan")).count();

        System.out.println(zhangsan);

        List<String> collect = strings.stream().map(string -> string.toUpperCase(Locale.ROOT)).collect(Collectors.toList());

        for (String s : collect) {
            System.out.println("s = " + s);
        }
    }
}
